<!DOCTYPE html>
<html lang="zh-cmn-Hans">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>拓深科技</title>
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    <link href="assets/bootstrap/css/bootstrap.min.css" rel="stylesheet"/>
    <link href="assets/font-awesome/css/font-awesome.min.css" rel="stylesheet"/>
    <link href="assets/ionicons-2.0.1/css/ionicons.min.css" rel="stylesheet"/>
    <link href="assets/AdminLTE/dist/css/AdminLTE.min.css" rel="stylesheet"/>
    <link href="assets/AdminLTE/dist/css/skins/_all-skins.min.css" rel="stylesheet"/>
    <link href="assets/vakata-jstree-7a976d1/dist/themes/default/style.min.css" rel="stylesheet"/>
    <link href="assets/jQuery-File-Upload-9.12.3/css/jquery.fileupload.css" rel="stylesheet"/>
    <link href="assets/jQuery-File-Upload-9.12.3/css/jquery.fileupload-ui.css" rel="stylesheet"/>
    <link href="assets/images/log.ico" rel="shortcut icon">
    <link href="assets/ipicture/css/iPicture_location.css" rel="stylesheet" media="screen"/>
</head>
<body class="hold-transition skin-red sidebar-mini">
<div class="wrapper">
    <!--顶部导航栏开始-->
    <header id="top_header" class="main-header">
        <!-- Logo -->
        <a href="main_page.html" class="logo">
            <!-- mini logo for sidebar mini 50x50 pixels -->
            <span class="logo-mini"><b>T</b>pson</span>
            <!-- logo for regular state and mobile devices -->
            <span class="logo-lg"><b>T</b>PSON</span>
        </a>
        <!-- Header Navbar: style can be found in header.less -->
        <nav class="navbar navbar-static-top" role="navigation">
            <!-- Sidebar toggle button-->
            <a href="#" class="sidebar-toggle" data-toggle="offcanvas" role="button">
                <span class="sr-only">Toggle navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </a>
            <div class="navbar-custom-menu">
                <ul class="nav navbar-nav">

                    <!-- User Account: style can be found in dropdown.less -->
                    <li class="dropdown user user-menu">
                        <a href="#" class="dropdown-toggle" data-toggle="dropdown">
                            <!--<img src="assets/dist/img/user2-160x160.jpg" class="user-image" alt="User Image">-->
                            <span class="hidden-xs">Administrator</span>
                        </a>
                    </li>
                    <!-- Control Sidebar Toggle Button -->
                </ul>
            </div>
        </nav>
    </header>
    <!--顶部导航栏结束-->
    <!--右侧导航栏开始-->
    <aside class="main-sidebar">
        <!-- sidebar: style can be found in sidebar.less -->
        <section class="sidebar">
            <!-- Sidebar user panel -->
            <!-- sidebar menu: : style can be found in sidebar.less -->
            <ul id="side_bar" class="sidebar-menu">
                <li class="header">导航栏</li>
                <li class="treeview">
                    <a href="main_page.html">
                        <i class="fa fa-dashboard text-red"></i>
                        <span>主页</span>
                    </a>
                </li>

                <li class="treeview">
                    <a href="alert_log.html">
                        <i class="fa fa-warning text-red"></i>
                        <span>报警记录</span>
                    </a>
                </li>
                <li class="treeview">
                    <a href="map_show.html">
                        <i class="fa fa-map-marker text-red"></i>
                        <span>地图展示</span>
                    </a>
                </li>
                <li class="treeview">
                    <a href="#">
                        <i class="fa fa-cog text-red"></i>
                        <span>设备管理</span>
                        <i class="fa fa-angle-left pull-right"></i>
                    </a>
                    <ul class="treeview-menu">
                        <!--<li><a href="router_status.html"><i class="fa fa-circle-o text-yellow"></i>设备状态 </a> </li>-->
                        <li><a href="router_config.html"><i class="fa fa-circle-o text-yellow"></i>设备配置 </a> </li>
                    </ul>
                </li>
                <li class="treeview active">
                    <a href="#">
                        <i class="fa fa-chain-broken text-red"></i>
                        <span>监测点配置</span>
                        <i class="fa fa-angle-left pull-right"></i>
                    </a>
                    <ul class="treeview-menu">
                        <li><a href="monitor_config_map_config.html"><i class="fa fa-circle-o text-red"></i>地图配置 </a> </li>
                        <li><a href="monitor_config_sensor_type_input.html"><i class="fa fa-circle-o text-yellow"></i>传感器类别设置 </a> </li>
                        <li><a href="monitor_config_monitor_input.html"><i class="fa fa-circle-o text-yellow"></i>监测点配置 </a> </li>
                        <li><a href="monitor_config_export.html"><i class="fa fa-circle-o text-yellow"></i>数据导入导出 </a> </li>
                    </ul>
                </li>

                <li id="sys_log" class="treeview">
                    <a href="show_log.html">
                        <i class="fa fa-files-o text-red"></i>
                        <span>系统日志</span>
                    </a>
                </li>
            </ul>
        </section>
        <!-- /.sidebar -->
    </aside>
    <!--右侧导航栏结束-->
    <!--内容区开始-->
    <div class="content-wrapper">
        <section class="content-header">
            <h1>
                <b>地图配置</b>
            </h1>
            <ol class="breadcrumb">
                <li><a href="main_page.html"><i class="fa fa-dashboard"></i> 主页</a></li>
                <li><a href="#"><i class="fa fa-chain-broken"></i> 监测点配置</a> </li>
                <li><a href="monitor_config_map_config.html"><i class="fa fa-circle-o"></i> 地图配置</a></li>
            </ol>
        </section>

        <!--<div class="pad margin no-print">-->
            <!--<div class="callout callout-info" style="margin-bottom: 0!important;">-->
                <!--<h4><i class="fa fa-info"></i> 提示：</h4>-->
                <!--录入或修改地理位置信息。-->
            <!--</div>-->
        <!--</div>-->

        <section class="invoice">
            <div class="row">
                <div class="col-md-3">
                    <div class="box box-warning">
                        <div class="box-header">
                            <h4 class="box-title"><b>当前区域数据</b></h4>
                        </div>
                        <div class="box-body">
                            <div id="loction_tree"></div>
                        </div>
                    </div>
                </div>
                <div class="col-md-9">
                    <div id="loction_setting" class="box box-warning">
                        <div class="box-header">
                            <h4 class="box-title"><b>地理信息设置</b></h4>
                        </div>
                        <div class="box-body">
                            <div class="row">
                                <div class="col-sm-12">
                                    <div class="nav-tabs-custom">
                                        <ul class="nav nav-tabs">
                                            <li class="active"><a href="#map_tab_floor" data-toggle="tab">楼层信息</a> </li>
                                            <li><a href="#map_tab_build" data-toggle="tab">建筑物信息</a> </li>
                                            <li><a href="#map_tab_area" data-toggle="tab">区域信息</a> </li>
                                        </ul>
                                        <div class="tab-content">
                                            <div class="tab-pane active" id="map_tab_floor">
                                                <div class="row">
                                                   <div class="box box-default">
                                                       <div class="box-header">
                                                           <h4 class="box-title">录入数据</h4>
                                                       </div>
                                                       <div class="box-body">
                                                           <div class="col-sm-12" id="floor_input_div">
                                                               <div class="col-sm-3">
                                                                   <div class="form-group">
                                                                       <label>区域</label>
                                                                       <select id="floor_input_div_area_select" class="form-control select2 floor_input_div_area_select_class" style="width: 100%;"></select>
                                                                   </div>
                                                               </div>
                                                               <div class="col-sm-3">
                                                                   <div class="form-group">
                                                                       <label>建筑物</label>
                                                                       <select id="floor_input_div_build_select" class="form-control select2 floor_input_div_build_select_class" style="width: 100%;"></select>
                                                                   </div>
                                                               </div>
                                                               <div class="col-sm-3">
                                                                   <div class="form-group">
                                                                       <label>楼层</label>
                                                                       <input id="mapFloorInput" type="text" class="form-control" placeholder="请输入楼层信息">
                                                                   </div>
                                                               </div>
                                                               <div class="col-sm-2 col-sm-offset-1">
                                                                   <button id="mapFloorSaveBtn" type="button" class="btn btn-success fa fa-save btn-block" style="margin-top: 28px">保存</button>
                                                               </div>
                                                           </div>
                                                       </div>
                                                   </div>
                                                    <div class="box box-default">
                                                        <div class="box-header">
                                                            <h4 class="box-title">删除数据</h4>
                                                        </div>
                                                        <div class="box-body">
                                                            <div class="col-sm-12" id="floor_del_div">
                                                                <div class="col-sm-3">
                                                                    <div class="form-group">
                                                                        <label>区域</label>
                                                                        <select id="floor_del_div_area_select" class="form-control select2 floor_del_div_area_select_class" style="width: 100%;"></select>
                                                                    </div>
                                                                </div>
                                                                <div class="col-sm-3">
                                                                    <div class="form-group">
                                                                        <label>建筑物</label>
                                                                        <select id="floor_del_div_build_select" class="form-control select2 floor_del_div_build_select_class" style="width: 100%;"></select>
                                                                    </div>
                                                                </div>
                                                                <div class="col-sm-3">
                                                                    <div class="form-group">
                                                                        <label>楼层</label>
                                                                        <select id="floor_del_div_floor_select" class="form-control select2 floor_del_div_floor_select_class" style="width: 100%;"></select>
                                                                    </div>
                                                                </div>
                                                                <div class="col-sm-2 col-sm-offset-1">
                                                                    <button id="mapFloorDelBtn" type="button" class="btn btn-danger fa fa-close btn-block " style="margin-top: 28px">删除</button>
                                                                </div>
                                                            </div>
                                                        </div>
                                                    </div>
                                                   <div class="box box-default">
                                                       <div class="box-header">
                                                           <h4 class="box-title">修改数据</h4>
                                                       </div>
                                                       <div class="box-body">
                                                           <div class="col-sm-12" id="floor_change_div">
                                                               <div class="col-sm-2">
                                                                   <div class="form-group">
                                                                       <label>区域</label>
                                                                       <select id="floor_change_div_area_select" class="form-control select2 floor_change_div_area_select_class" style="width: 100%;"></select>
                                                                   </div>
                                                               </div>
                                                               <div class="col-sm-2">
                                                                   <div class="form-group">
                                                                       <label>建筑物</label>
                                                                       <select id="floor_change_div_build_select" class="form-control select2 floor_change_div_build_select_class" style="width: 100%;"></select>
                                                                   </div>
                                                               </div>
                                                               <div class="col-sm-2">
                                                                   <div class="form-group">
                                                                       <label>原始楼层</label>
                                                                       <select id="floor_change_div_floor_select" class="form-control select2 floor_change_div_floor_select_class" style="width: 100%;"></select>
                                                                   </div>
                                                               </div>
                                                               <div class="col-sm-2">
                                                                   <div class="form-group">
                                                                       <label>修改楼层</label>
                                                                       <input id="mapFloorChangeInput" type="text" class="form-control" placeholder="请输入楼层信息">
                                                                   </div>
                                                               </div>
                                                               <div class="col-sm-2 col-sm-offset-2">
                                                                   <button id="mapFloorChangeBtn" type="button" class="btn btn-warning fa  fa-file-text btn-block " style="margin-top: 28px">修改</button>
                                                               </div>
                                                           </div>
                                                       </div>
                                                   </div>

                                                </div>

                                            </div>
                                            <div class="tab-pane" id="map_tab_build">
                                                <div class="row">
                                                    <div class="col-sm-12">
                                                        <div class="box box-default">
                                                            <div class="box-header">
                                                                <h3 class="box-title">录入数据</h3>
                                                            </div>
                                                            <div class="box-body">
                                                                <div class="col-sm-12" id="build_input_div">
                                                                    <div class="col-sm-3">
                                                                        <div class="form-group">
                                                                            <label>区域</label>
                                                                            <select id="build_input_div_area_select" class="form-control select2 build_input_div_area_select_class" style="width: 100%;"></select>
                                                                        </div>
                                                                    </div>
                                                                    <div class="col-sm-3">
                                                                        <div class="form-group">
                                                                            <label>建筑物</label>
                                                                            <input id="mapBuildInput" type="text" class="form-control" placeholder="请输入建筑物名称">
                                                                        </div>
                                                                    </div>
                                                                    <div class="col-sm-2 col-sm-offset-1">
                                                                        <button id="mapBuildSaveBtn" type="button" class="btn btn-success fa fa-save btn-block " style="margin-top: 28px">保存</button>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                        </div>
                                                    </div>
                                                    <div class="col-sm-12">
                                                        <div class="box box-default">
                                                            <div class="box-header">
                                                                <h3 class="box-title">删除数据</h3>
                                                            </div>
                                                            <div class="box-body">
                                                                <div class="col-sm-12" id="build_del_div">
                                                                    <div class="col-sm-3">
                                                                        <div class="form-group">
                                                                            <label>区域</label>
                                                                            <select id="build_del_div_area_select" class="form-control select2 build_del_div_area_select_class" style="width: 100%;"></select>
                                                                        </div>
                                                                    </div>
                                                                    <div class="col-sm-3">
                                                                        <div class="form-group">
                                                                            <label>建筑物</label>
                                                                            <select id="build_del_div_build_select" class="form-control select2 build_del_div_build_select_class" style="width: 100%;"></select>
                                                                        </div>
                                                                    </div>
                                                                    <div class="col-sm-2 col-sm-offset-1">
                                                                        <button id="mapBuildDelBtn" type="button" class="btn btn-danger fa fa-close btn-block " style="margin-top: 28px">删除</button>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                        </div>
                                                    </div>
                                                    <div class="col-sm-12">
                                                        <div class="box box-default" >
                                                            <div class="box-header">
                                                                <h3 class="box-title">修改数据</h3>
                                                            </div>
                                                            <div class="box-body">
                                                                <div class="col-sm-12" id="build_change_div">
                                                                    <div class="col-sm-3">
                                                                        <div class="form-group">
                                                                            <label>区域</label>
                                                                            <select id="build_change_div_area_select" class="form-control select2 build_change_div_area_select_class" style="width: 100%;"></select>
                                                                        </div>
                                                                    </div>
                                                                    <div class="col-sm-3">
                                                                        <div class="form-group">
                                                                            <label>原始建筑物</label>
                                                                            <select id="build_change_div_build_select" class="form-control select2 build_change_div_build_select_class" style="width: 100%;"></select>
                                                                        </div>
                                                                    </div>
                                                                    <div class="col-sm-3">
                                                                        <div class="form-group">
                                                                            <label>修改建筑物</label>
                                                                            <input id="mapBuildChangeInput" type="text" class="form-control" placeholder="请输入建筑物名称">
                                                                        </div>
                                                                    </div>
                                                                    <div class="col-sm-2 col-sm-offset-1">
                                                                        <button id="mapBuildChangeBtn" type="button" class="btn btn-warning fa  fa-file-text btn-block " style="margin-top: 28px">修改</button>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="tab-pane" id="map_tab_area">
                                                <div class="row">
                                                    <div class="col-sm-12">
                                                        <div class="box box-default">
                                                            <div class="box-header">
                                                                <h4 class="box-title">录入数据</h4>
                                                            </div>
                                                            <div class="box-body">
                                                                <div class="col-sm-12">
                                                                    <div class="col-sm-3">
                                                                        <div class="form-group">
                                                                            <label>区域数据</label>
                                                                            <input id="mapAreaInput" type="text" class="form-control" placeholder="请输入区域名称">
                                                                        </div>
                                                                    </div>
                                                                    <div class="col-sm-2 col-sm-offset-1">
                                                                        <button id="mapAreaSaveBtn" type="button" class="btn btn-success btn-block fa fa-save" style="margin-top: 28px">保存</button>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                        </div>
                                                    </div>
                                                    <div class="col-sm-12">
                                                        <div class="box box-default">
                                                            <div class="box-header">
                                                                <h4 class="box-title">删除数据</h4>
                                                            </div>
                                                            <div class="box-body">
                                                                <div class="col-sm-12" id="area_del_div">
                                                                    <div class="col-sm-3">
                                                                        <div class="form-group">
                                                                            <label>区域数据</label>
                                                                            <select id="area_del_div_area_select" class="form-control select2 area_del_div_area_select_class" style="width: 100%;"></select>
                                                                        </div>
                                                                    </div>
                                                                    <div class="col-sm-2 col-sm-offset-1">
                                                                        <div class="form-group">
                                                                            <button id="mapAreaDelBtn" type="button" class="btn btn-danger btn-block fa fa-close" style="margin-top: 28px">删除</button>
                                                                        </div>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                        </div>
                                                    </div>
                                                    <div class="col-sm-12">
                                                        <div class="box box-default">
                                                            <div class="box-header">
                                                                <h4 class="box-title">修改数据</h4>
                                                            </div>
                                                            <div class="box-body">
                                                                <div class="col-sm-12" id="area_change_div">
                                                                    <div class="col-sm-3">
                                                                        <div class="form-group">
                                                                            <label>原始区域数据</label>
                                                                            <select id="area_change_div_area_select" class="form-control select2 area_change_div_area_select_class" style="width: 100%;"></select>
                                                                        </div>
                                                                    </div>
                                                                    <div class="col-sm-3">
                                                                        <div class="form-group">
                                                                            <label>修改数据</label>
                                                                            <input id="mapAreaChangeInput" type="text" class="form-control" placeholder="请输入区域信息">
                                                                        </div>
                                                                    </div>
                                                                    <div class="col-sm-2 col-sm-offset-1">
                                                                        <button id="mapAreaChangeBtn" type="button" class="btn btn-warning fa  fa-file-text btn-block " style="margin-top: 28px">修改</button>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="row">
                                <div class="box box-success" style="margin-bottom: 0px">
                                    <div class="box-header">
                                        <h4 class="box-title">修改地图数据(<b style="color: red">!点击左侧区域再进行图片上传</b>)</h4>
                                    </div>
                                    <div class="box-body">
                                        <div class="row">
                                            <div class="col-sm-2"><input id="photoCover" class="input-large" type="text" style="height:33px;display: none" disabled></div>
                                            <div class="col-sm-2"  >
                                                <form id="fileForm" action="" method="post" enctype="multipart/form-data"   target="frameFile" >
                                                    <span class="btn btn-info fa fa-folder-open   fileinput-button">
                                                    <!--<i class="glyphicon glyphicon-plus"></i>-->
                                                    <span>打开地图</span>
                                                    <input id="map_file" type="file" multiple  name="file" accept="image/jpeg,image/png">
                                                </span>
                                               <input id="submit" name="submit" type="submit" style="display: none">
                                            </form>
                                           <iframe id="frameFile" name="frameFile" style="display: none;"></iframe>
                                       </div>
                                   </div>
                                  </div>
                              </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </section>

        <div class="clearfix"></div>
    </div><!-- /.content-wrapper -->
    <!--内容区结束-->
    <!--页脚开始-->
    <footer class="main-footer no-print">
        <div class="pull-right hidden-xs">
            <b>Version</b>  3.1.4
        </div>
        <strong>Copyright &copy; 2015-2016 <a href="http://www.tpson.cn/" target="_blank">拓深科技</a>.</strong> All rights reserved.
    </footer>
    <!--页脚结束-->
</div>

<script src="assets/plugins/jQuery/jQuery-2.1.4.min.js"></script>
<script src="assets/bootstrap/js/bootstrap.min.js"></script>
<script src="assets/plugins/fastclick/fastclick.min.js"></script>
<script src="assets/AdminLTE/dist/js/app.min.js"></script>
<script src="assets/AdminLTE/dist/js/demo.js"></script>
<script src="assets/vakata-jstree-7a976d1/dist/jstree.min.js"></script>
<script src="assets/layer-v2.2/layer/layer.js"></script>
<script src="assets/cxSelect-master/js/jquery.cxselect.min.js"></script>
<script src="assets/ipicture/js/jquery.ipicture_location.js"></script>
<script src="js/alert_check.js"></script>
<script>
    var server;
    var mapId;
//    var data = [];
    var locationObjArr;
    $(function () {
        var path = document.location.pathname;
        var href = document.location.href;
        if(path =='/'){
            var index = href.indexOf(path,href.indexOf(path)+2);
        }else {
            var index = href.indexOf(path);
        }
        var localPath = href.substring(0,index);
        var localName = path.substring(0,path.substr(1).indexOf('/')+1);
        server = localPath + localName;
        socketInit(server.substring(5));
        init();
        treeinit();
        window.onload = checkAlert(server);
    });
    function init() {
        $.ajax({
            url: server + "/xk/xkGeoLocation/getTree",
            async:false,
            success:function (data_in) {
                var jsonObj = JSON.parse(data_in);
                var data = [];
                for(var i  in jsonObj.data){
                    var level1 = jsonObj.data;
                    if(i==0){
                        var level1Obj = {
                            text:level1[i].name,
                            id:level1[i].id,
                            icon:"glyphicon glyphicon-globe text-yellow",
                            state: {"opened" : true }
                        };
                    }else {
                        var level1Obj = {
                            text:level1[i].name,
                            id:level1[i].id,
                            icon:"glyphicon glyphicon-globe text-yellow",
                            state: {"opened" : false }
                        };
                    }
                    if(level1[i].picture ==""){
                        level1Obj.text = level1[i].name + "(无地图)";
                    }
                    if(level1[i].children != null)
                    {
                        var level2 = level1[i].children;
                        var level2Arr = [];
                        for(var j in level2){
                            if(i==0 && j==0){
                                var level2Obj = {
                                    text: level2[j].name,
                                    id: level2[j].id,
                                    icon: "glyphicon glyphicon-home text-yellow",
                                    state: {"opened" : true }
                                };
                            }else {
                                var level2Obj = {
                                    text: level2[j].name,
                                    id: level2[j].id,
                                    icon: "glyphicon glyphicon-home text-yellow",
                                    state: {"opened" : false }
                                };
                            }
                            if(level2[j].picture ==""){
                                level2Obj.text = level2[j].name + "(无地图)";
                            }
                            if(level2[j].children != null)
                            {
                                var level3 = level2[j].children;
                                var level3Arr = [];
                                for(var k in level3){
                                    var level3Obj = {
                                        text: level3[k].name,
                                        id: level3[k].id,
                                        icon: "glyphicon glyphicon-flag text-yellow"
                                    };
                                    if(level3[k].picture ==""){
                                        level3Obj.text = level3[k].name + "(无地图)";
                                    }
                                    level3Arr.push(level3Obj);
                                }
                                level2Obj .children = level3Arr;
                            }
                            level2Arr.push(level2Obj);
                        }
                        level1Obj.children = level2Arr;
                    }
                    data.push(level1Obj);
                }
                locationObjArr = data;
                console.log(locationObjArr);
            },
        });

        $('#floor_input_div').cxSelect({
            selects:['floor_input_div_area_select_class','floor_input_div_build_select_class',],
            jsonName:'text',
            jsonValue:'id',
            jsonSub:'children',
            data:locationObjArr
        });
        $('#floor_del_div').cxSelect({
            selects:['floor_del_div_area_select_class','floor_del_div_build_select_class','floor_del_div_floor_select_class'],
            jsonName:'text',
            jsonValue:'id',
            jsonSub:'children',
            data:locationObjArr
        });
        $('#floor_change_div').cxSelect({
            selects:['floor_change_div_area_select_class','floor_change_div_build_select_class','floor_change_div_floor_select_class'],
            jsonName:'text',
            jsonValue:'id',
            jsonSub:'children',
            data:locationObjArr
        });

        $('#build_input_div').cxSelect({
            selects:['build_input_div_area_select_class',],
            jsonName:'text',
            jsonValue:'id',
            data:locationObjArr
        });
        $('#build_del_div').cxSelect({
            selects:['build_del_div_area_select_class','build_del_div_build_select_class'],
            jsonName:'text',
            jsonValue:'id',
            jsonSub:'children',
            data:locationObjArr
        });
        $('#build_change_div').cxSelect({
            selects:['build_change_div_area_select_class','build_change_div_build_select_class'],
            jsonName:'text',
            jsonValue:'id',
            jsonSub:'children',
            data:locationObjArr
        });

        $('#area_del_div').cxSelect({
            selects:['area_del_div_area_select_class'],
            jsonName:'text',
            jsonValue:'id',
            data:locationObjArr
        });
        $('#area_change_div').cxSelect({
            selects:['area_change_div_area_select_class'],
            jsonName:'text',
            jsonValue:'id',
            data:locationObjArr
        });
    };
    function treeinit(){
        $('#loction_tree').data('jstree',false).empty();
        $('#loction_tree').jstree({
            'core' : {
                'data' : locationObjArr,
                'async' : true,
            }
        });
    }
    $('#loction_tree').on('select_node.jstree', function (e, data) {
        $('#loction_tree').jstree("uncheck_all");
        mapId = data.node.id;
        console.log(mapId);
        loadServerMap(mapId);
    });
    //图片上传
    $('#upload').click(function(){
        $('#fileForm').attr("action",server +"/xk/xkGeoLocation/mapUpload?id="+mapId);
        $('#submit').click();
        $('#fileName').empty();
        $('#fileName').html("附件体积请勿超过20MB.")

    })
    function getObjectURL(file) {
        //获取图片路径
        var url = null;
        if (window.createObjectURL != undefined) { // basic
            url = window.createObjectURL(file);
        } else if (window.URL != undefined) { // mozilla(firefox)
            url = window.URL.createObjectURL(file);
        } else if (window.webkitURL != undefined) { // webkit or chrome
            url = window.webkitURL.createObjectURL(file);
        }
        return url;
    }
    //图片预览上传
    $('input[id=map_file]').change(function() {
        var mp = $('#photoCover');
        mp.val($(this).val());
        if(mp.val() != null){
            var objUrl = getObjectURL(this.files[0]) ;
            if (objUrl) {
                layer.open({
                    type:1,
                    area: ['800px', '600px'],
                    title: '地图上传',
                    skin:'layui-layer-lan',
                    content:'<div class="row"><div id="map_div_layer" ></div></div>',
                    btn:['确认上传','取消'],
                    btn1:function (index, layero) {
                        var formData = new FormData($("#fileForm")[0]);
                        $.ajax({
                            async: false,
                            cache: false,
                            contentType: false,
                            processData: false,
                            url:server +"/xk/xkGeoLocation/mapUpload?id="+mapId,
                            type:"post",
                            data:formData,
                            success:function(data){
                                layer.alert('图片上传成功！',{
                                    closeBtn: 0
                                });
                                layer.close(index);
                                $('#map_file').val(null);
                                $('#photoCover').val(null);
//                                location.reload();
                            },
                            error:function(data){
                                console.log("error");
                                layer.close(index);
                            }
                        })
                    },
                    btn2:function (index, layero) {
                        $('#map_div').empty();
                        $('#map_file').val(null);
                        $('#photoCover').val(null);
                        layer.close(index);
                    },
                    success:function(){
                        $('#map_div_layer').empty();
                        var img = '<img id="show_map" class="col-sm-12" src="'+objUrl+'" />';
                        $('#map_div_layer').append(img);
                        mp.val(objUrl);
                    }
                })

            }
        }
    });
    //图片显示
    function loadServerMap(id) {
        layer.open({
            type: 1,
            title: false,
            closeBtn: 0,
            area: '516px',
            offset:['30%','40%'],
            border:false,
            skin: 'layui-layer-nobg', //没有背景色
            shadeClose: true,
            content: '<img id="show_map"style="width: 100%;height: 100%" src="'+server+'/xk/xkGeoLocation/mapDownload?id='+id+'" />'
        });
    }
    function clear() {
        $('#loction_tree').empty();
    }
    //录入楼层数据
    $('#mapFloorSaveBtn').click(function () {
        if($('#floor_input_div_build_select').val() == null || $('#mapFloorInput').val()[0] == null){
            layer.alert('请输入完整的筛选信息！',{
                closeBtn: 0
            });
        }else{
            var parentID = $('#floor_input_div_build_select').val();
            var name = $('#mapFloorInput').val();
            var formDatas = new FormData();
            formDatas.append("name",name);
            console.log(name);
            formDatas.append("parent_id",parentID);
            console.log(parentID);
            formDatas.append("level",3);
            $.ajax({
                type:"post",
                contentType : false,
                processData:false,
                url: server + "/xk/xkGeoLocation/add",
                data:formDatas,
                success:function (data) {
                    if(JSON.parse(data).code == 0){
                        location.reload();
                    }
                    else{
                        layer.alert('操作失败：' + data,{
                            closeBtn: 0
                        });
                    }
                }
            });
        }
    });
    //删除楼层数据
    $('#mapFloorDelBtn').click(function () {
        if($('#floor_del_div_floor_select').val() == null){
            layer.alert('请输入完整的筛选信息！',{
                closeBtn: 0
            });
        }else{
            var ID = $('#floor_del_div_floor_select').val();
            $.ajax({
                url: server + "/xk/xkGeoLocation/delete?id=" + ID,
                success:function (data) {
                    if(JSON.parse(data).code == 0){
//                        clear();
//                        init();
                        location.reload();
                    }
                    else{
                        layer.alert('操作失败：' + data,{
                            closeBtn: 0
                        });
                    }
                }
            });
        }
    });
    //修改楼层数据
    $('#mapFloorChangeBtn').click(function () {
        if($('#floor_change_div_floor_select').val() == null || $('#mapFloorChangeInput').val()[0] == null){
            layer.alert('请输入完整的筛选信息！',{
                closeBtn: 0
            });
        }else{
            var ID = $('#floor_change_div_floor_select').val();
            var parentID = $('#floor_change_div_build_select').val();
            var name = $('#mapFloorChangeInput').val();
            var formDatas = new FormData();
            formDatas.append("id",ID);
            formDatas.append("name",name);
            formDatas.append("parent_id",parentID);
            formDatas.append("level",3);
            $.ajax({
                type:"post",
                contentType : false,
                processData:false,
                url: server + "/xk/xkGeoLocation/update",
                data:formDatas,
                success:function (data) {
                    if(JSON.parse(data).code == 0){
//                        clear();
//                        init();
//                        treeinit();
                        location.reload();
                    }
                    else{
                        layer.alert('操作失败：' + data,{
                            closeBtn: 0
                        });
                    }
                }
            });
        }
    });
    //录入建筑数据
    $('#mapBuildSaveBtn').click(function () {
        if($('#build_input_div_area_select').val() == null || $('#mapBuildInput').val()[0] == null){
            layer.alert('请输入完整的筛选信息！',{
                closeBtn: 0
            });
        }else{
            var parentID = $('#build_input_div_area_select').val();
            var name = $('#mapBuildInput').val();
            var formDatas = new FormData();
            formDatas.append("name",name);
            formDatas.append("parent_id",parentID);
            formDatas.append("level",2);
            console.log(name);
            console.log(parentID);
            $.ajax({
                type:"post",
                contentType : false,
                processData:false,
                url: server + "/xk/xkGeoLocation/add",
                data:formDatas,
                success:function (data) {
                    if(JSON.parse(data).code == 0){
//                        clear();
//                        init();
                        location.reload();
                    }
                    else{
                        layer.alert('操作失败：' + data,{
                            closeBtn: 0
                        });
                    }
                }
            });
        }
    });
    //删除建筑物数据
    $('#mapBuildDelBtn').click(function () {
        if($('#build_del_div_build_select').val() == null){
            layer.alert('请输入完整的筛选信息！',{
                closeBtn: 0
            });
        }else{
            var ID = $('#build_del_div_build_select').val();
            console.log(ID);
            $.ajax({
                url: server + "/xk/xkGeoLocation/delete?id="+ID,
                success:function (data) {
                    if(JSON.parse(data).code == 0){
//                        clear();
//                        init();
                        location.reload();
                    }
                    else{
                        layer.alert('操作失败：' + data,{
                            closeBtn: 0
                        });
                    }
                }
            });
        }
    });
    //修改建筑物数据
    $('#mapBuildChangeBtn').click(function () {
        if($('#build_change_div_build_select').val() == null || $('#mapBuildChangeInput').val()[0] == null){
            layer.alert('请输入完整的筛选信息！',{
                closeBtn: 0
            });
        }else{
            var ID = $('#build_change_div_build_select').val();
            var parentID = $('#build_change_div_area_select').val();
            var name = $('#mapBuildChangeInput').val();
            var formDatas = new FormData();
            formDatas.append("id",ID);
            formDatas.append("name",name);
            formDatas.append("parent_id",parentID);
            formDatas.append("level",2);
            $.ajax({
                type:"post",
                contentType : false,
                processData:false,
                url: server + "/xk/xkGeoLocation/update" ,
                data:formDatas,
                success:function (data) {
                    if(JSON.parse(data).code == 0){
//                        clear();
//                        init();
                        location.reload();
                    }
                    else{
                        layer.alert('操作失败：' + data,{
                            closeBtn: 0
                        });
                    }
                }
            });
        }
    });
    //录入区域数据
    $('#mapAreaSaveBtn').click(function () {
        if($('#mapAreaInput').val() == null){
            layer.alert('请输入完整的筛选信息！',{
                closeBtn: 0
            });
        }else{
            var name = $('#mapAreaInput').val();
            var formDatas = new FormData();
            formDatas.append("name",name);
            formDatas.append("parent_id",0);
            formDatas.append("level",1);
            $.ajax({
                type:"post",
                contentType : false,
                processData:false,
                url: server + "/xk/xkGeoLocation/add" ,
                data:formDatas,
                success:function (data) {
                    if(JSON.parse(data).code == 0){
//                        clear();
//                        init();
                        location.reload();
                    }
                    else{
                        layer.alert('操作失败：' + data,{
                            closeBtn: 0
                        });
                    }
                }
            });
        }
    });
    //删除区域数据
    $('#mapAreaDelBtn').click(function () {
        if($('#area_del_div_area_select').val() == null){
            layer.alert('请输入完整的筛选信息！',{
                closeBtn: 0
            });
        }else{
            var ID = $('#area_del_div_area_select').val();
            $.ajax({
                url: server + "/xk/xkGeoLocation/delete?id=" + ID,
                success:function (data) {
                    if(JSON.parse(data).code == 0){
//                        clear();
//                        init();
                        location.reload();
                    }
                    else{
                        layer.alert('操作失败：' + data,{
                            closeBtn: 0
                        });
                    }
                }
            });
        }
    });
    //修改区域数据
    $('#mapAreaChangeBtn').click(function () {
        if($('#area_change_div_area_select').val() == null || $('#mapAreaChangeInput').val()[0] == null){
            layer.alert('请输入完整的筛选信息！',{
                closeBtn: 0
            });
        }else{
            var ID = parseInt($('#area_change_div_area_select').val());
            var name = $('#mapAreaChangeInput').val();
            var formDatas = new FormData();
            formDatas.append("id",ID);
            formDatas.append("name",name);
            formDatas.append("parent_id",0);
            formDatas.append("level",1);
            $.ajax({
                type:"post",
                contentType : false,
                processData:false,
                url: server + "/xk/xkGeoLocation/update",
                data:formDatas,
                success:function (data) {
                    if(JSON.parse(data).code == 0){
//                        clear();
//                        init();
                        location.reload();
                    }
                    else{
                        layer.alert('操作失败：' + data,{
                            closeBtn: 0
                        });
                    }
                }
            });
        }
    });
</script>
</body>
</html>